package edu.uta.iconverter.converter;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


public class CommonDictionary {
    /*
    * Function to load to the dictionary from the file 
    * returns dictionary object
    */
    
    public HashSet<String> loadDictionaryFromFile(String filename) throws FileNotFoundException, IOException{
        
        HashSet<String> dictionary = new HashSet<String>();
        BufferedReader bufferReader = new BufferedReader(new FileReader("resources/CommonDictionary.txt"));                     
                       
        String line = "";
        
        while( (line = bufferReader.readLine()) != null){
            String[] word_list = line.split("\\s+");
            for(int i = 0 ; i < word_list.length; i++ )
            	dictionary.add(word_list[i]);
        }
       
        //System.out.println("Size -->>> "+dictionary.size());
        bufferReader.close();
        return dictionary;
    } 
    
}

